using Circus.CodeEditor;

using System;
using System.ComponentModel;
namespace Circus.Syntax.CodeCompletion
{
	public class CodeSnippetHeader : ICodeSnippetHeader, IComparable
	{
		private string title = string.Empty;
		private string description = string.Empty;
		private string author = string.Empty;
		private string shortcut = string.Empty;
		private CodeSnippetTypes types;
		public virtual string Title
		{
			get
			{
				return this.title;
			}
			set
			{
				if (this.title != value)
				{
					this.title = value;
					this.OnTitleChanged();
				}
			}
		}
		public virtual string Description
		{
			get
			{
				return this.description;
			}
			set
			{
				if (this.description != value)
				{
					this.description = value;
					this.OnDescriptionChanged();
				}
			}
		}
		public virtual string Author
		{
			get
			{
				return this.author;
			}
			set
			{
				if (this.author != value)
				{
					this.author = value;
					this.OnAuthorChanged();
				}
			}
		}
		public virtual string Shortcut
		{
			get
			{
				return this.shortcut;
			}
			set
			{
				if (this.shortcut != value)
				{
					this.shortcut = value;
					this.OnShortcutChanged();
				}
			}
		}
		public virtual ICodeSnippetTypes Types
		{
			get
			{
				return this.types;
			}
		}
		
		protected virtual void OnTitleChanged()
		{
		}
		protected virtual void OnDescriptionChanged()
		{
		}
		protected virtual void OnAuthorChanged()
		{
		}
		protected virtual void OnShortcutChanged()
		{
		}
		public CodeSnippetHeader()
		{
			this.types = new CodeSnippetTypes();
		}
		public virtual void Assign(ICodeSnippetHeader source)
		{
			this.Title = source.Title;
			this.Description = source.Description;
			this.Author = source.Author;
			this.Shortcut = source.Shortcut;
			this.types.Clear();
			foreach (ICodeSnippetType current in source.Types)
			{
				this.types.AddSnippetType().SnippetType = current.SnippetType;
			}
		}
		public virtual int CompareTo(object value)
		{
			if (value is ICodeSnippetHeader)
			{
				return string.Compare(this.title, ((ICodeSnippetHeader)value).Title, true);
			}
			throw new ArgumentException();
		}
	}
}
